#include "stdafx.h"
#include "StatCalculator.h"

using namespace std;

StatCalculator :: StatCalculator(list<Hand> handList_)
{
	if (handList_.empty()) // how do i make sure the _handlist object isn't null?
		assert(0);
	this->InitializeHandList(handList_);
}

void StatCalculator :: InitializeHandList(list<Hand> handList_)
{
	// Set handList
	(this->handList).assign(handList_.begin(),handList_.end());

	list<Hand>::iterator handIt;
	list<Player>::iterator playerIt;

	// For each hand
	for(handIt = this->handList.begin(); handIt != this->handList.end(); handIt++)
	{
		list<Player> playerList((*handIt).Players());
		// For each player playing in the hand
		for (playerIt = playerList.begin(); playerIt != playerList.end(); playerIt++)
		{
			// If the player is not found in map, add it
			if ((this->playerStats).find((*playerIt).Name()) == (this->playerStats).end())
			{
				Stat s;
				(this->playerStats).insert(pair<string,Stat>((*playerIt).Name(), s));
			}
		}
	}
}

//float StatCalculator :: MoneyWonPerHand() const
//{
//	
//	return (float)0;
//}